<?php

namespace app\modules\goodsdetail\controllers;

use Yii;
use yii\web\Controller;
use common\models\Tools;
use common\models\Goods;

/**
 * 
 */
class DefaultController extends Controller
{
    /**
     * 商品详情页
     */
    public function actionIndex()
    {
        $goods_id = Tools::GetSafeParam('goods_id', 0, 0);
        
        if($goods_id == 0){
            \common\models\Tools::get_show_msg('/', '商品ID错误！', 0, 3);
        }
        
        $data = Goods::getGoodsDetail($goods_id);
        
        if($data['first_cate']==1 && $data['have_package']==1){//道闸类型的商品，跳转到该商家的道闸集合页内
            return $this->redirect('/goodsdetail/daozha?id='.$data['seller_id']);
        }
        
        $data['status_arr'] = array(0=>'待审核',1=>'正出售',2=>'已下架',3=>'未通过',4=>'已删除');
        //echo "<pre>"; print_r($data);exit;
		$this->getView()->title = $data['name'];
        return $this->render('index',[
            'data'=>$data,
            'backend_server'=>Yii::$app->params['backend_server']
            ]);
    }
}
